package servlet;

import Hbase.AlterStudnet;
import pojo.ST;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

@WebServlet("/AlterServlet2")
public class AlterServlet2 extends HttpServlet {
    public void init (HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        resp.setCharacterEncoding("utf-8");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("zzzzzzz");
        init(req,resp);
        String status=req.getParameter("op");
        String ID=req.getParameter("id");

        System.out.println(ID);
        System.out.println(status);
        ST li=new ST();
        li.setStudentID(ID);
        li.setStudentStatus(status);

        AlterStudnet alterStudnet = new AlterStudnet();
        alterStudnet.alter(li);
        resp.setContentType("text/html;charset=utf-8");

        HttpSession session = req.getSession();

        req.setAttribute("obj_data2","更新成功");

        req.getRequestDispatcher("/Alter.jsp").forward(req,resp);

    }
}
